/*
 * @Author: 卡卡 1071780426@qq.com
 * @Date: 2023-03-21 12:16:15
 * @LastEditors: 贺楠 1071780426@qq.com
 * @LastEditTime: 2024-09-10 14:05:44
 * @FilePath: \mould\src\utils\date.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */


export default {
    getDay(day) {
        var today = new Date();
        var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day;
        today.setTime(targetday_milliseconds); //注意，这行是关键代码
        var tYear = today.getFullYear();
        var tMonth = today.getMonth();
        var tDate = today.getDate();
        tMonth = this.doHandleMonth(tMonth + 1);
        tDate = this.doHandleMonth(tDate);
        return tYear + "-" + tMonth + "-" + tDate;
    },
    
    getDay2(day) {
        var today = new Date();
        var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day;
        today.setTime(targetday_milliseconds); //注意，这行是关键代码
        var tYear = today.getFullYear();
        var tMonth = today.getMonth();
        var tDate = today.getDate();
        tMonth = this.doHandleMonth(tMonth + 1);
        tDate = this.doHandleMonth(tDate);
        return tYear + "年" + tMonth + "月" + tDate+"日";
    },
    getYear(day) {
        var today = new Date();
        var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day;
        today.setTime(targetday_milliseconds); //注意，这行是关键代码
        var tYear = today.getFullYear();

        return tYear + '';
    },
    getMonth(day) {
        var today = new Date();
        var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day;
        today.setTime(targetday_milliseconds); //注意，这行是关键代码

        var tMonth = today.getMonth();

        tMonth = tMonth + 1;

        return tMonth + '月份';
    },
    getMonths(day) {
        var today = new Date();
        var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day;
        today.setTime(targetday_milliseconds); //注意，这行是关键代码

        var tMonth = today.getMonth();

        tMonth = tMonth + 1;

        return tMonth
    },
    doHandleMonth(month) {
        var m = month;
        if (month.toString().length == 1) {
            m = "0" + month;
        }
        return m;
    },
    getDays() {
        var time = new Date();

        const hh = (time.getHours() + "").padStart(2, "0");
        const mm = (time.getMinutes() + "").padStart(2, "0");
        const ss = (time.getSeconds() + "").padStart(2, "0");
        return hh + ":" + mm + ":" + ss;
    },

    getAllDay(day) {
        var today = new Date();
        var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day;
        today.setTime(targetday_milliseconds); //注意，这行是关键代码
        var tYear = today.getFullYear();
        var tMonth = today.getMonth();
        var tDate = today.getDate();
        tMonth = this.doHandleMonth(tMonth + 1);
        tDate = this.doHandleMonth(tDate);
        const hh = (today.getHours() + "").padStart(2, "0");
        const mm = (today.getMinutes() + "").padStart(2, "0");
        const ss = (today.getSeconds() + "").padStart(2, "0");
        return tYear + "-" + tMonth + "-" + tDate + " " + hh + ":" + mm + ":" + ss;
    },
    day(day) {
        var today = new Date();
        var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day;
        today.setTime(targetday_milliseconds); //注意，这行是关键代码
        var tYear = today.getFullYear();
        var tMonth = today.getMonth();
        var tDate = today.getDate();
        tMonth = this.doHandleMonth(tMonth + 1);
        tDate = this.doHandleMonth(tDate);
      
        return tYear + "-" + tMonth + "-" + tDate ;
    },
    daye(day) {
        var today = new Date();
        var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day;
        today.setTime(targetday_milliseconds); //注意，这行是关键代码
   
        var tDate = today.getDate();
        tDate = this.doHandleMonth(tDate);
      
        return tDate ;
    }
}